package course.view;

import java.awt.Color;
<<<<<<< HEAD
import java.awt.Component;
import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;

import javax.swing.ButtonGroup;
import javax.swing.JButton;
import javax.swing.JDialog;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JRadioButton;
import javax.swing.JTextField;
import course.controller.CourseControllerListener;
import course.po.Dean;

public class DeanDialog extends JDialog {
	private static final long serialVersionUID = 1L;
	private CourseControllerListener courseControllerListener;
	private JButton confirmButton;
	private JPanel deanAddPanel;
	private Dean dean;
	private JTextField deanIdTextField;
	private JTextField deanNoTextField;
	private JTextField deanNameTextField;
	private JTextField deanSexTextField;
	private JTextField deanAgeTextField;
	public static JRadioButton radioMan;
	public static JRadioButton radioFemal;

	public DeanDialog(DeanJPanel owner, String title, Dean dean) {
		this.courseControllerListener = owner.getControllerListener();
		this.courseControllerListener.setDeanAddDialog(this);
		this.setTitle(title);
		this.dean = dean;
		this.add(getDeanAddPanel());
		this.setModal(true); // 设有模
		this.setSize(370, 530);
		this.setLocationRelativeTo(null);
		this.setModalityType(ModalityType.DOCUMENT_MODAL);//DOCUMENT_MODAL对话框阻止来自同一文档的所有顶级窗口的输入，但来自其自己的子层次结构的窗口除外。
		this.setResizable(false);
		this.setVisible(true);
		this.validate();
	}

	public void closeCurrentDialog() {
		this.setDefaultCloseOperation(DISPOSE_ON_CLOSE);
	}

	/**
	 * 添加/修改表单面板
	 * 
	 * @return
	 */
	private JPanel getDeanAddPanel() {
		deanAddPanel = new JPanel();
		deanAddPanel.setBackground(Color.orange);
		if ("添加教务员".equals(this.getTitle())) {
			radioMan = new JRadioButton("男");
			radioFemal = new JRadioButton("女");
			ButtonGroup group = new ButtonGroup();
			group.add(radioMan);
			group.add(radioFemal);
			deanIdTextField = new JTextField(30);
			deanNoTextField = new JTextField(30);
			deanNameTextField = new JTextField(30);
//			deanSexTextField = new JTextField(30);
			deanAgeTextField = new JTextField(30);
			deanAgeTextField.addKeyListener(new KeyAdapter() {
				public void keyTyped(KeyEvent e) {
				new FunctionFrame();
			
				deanAgeTextField.setText(String.valueOf(FunctionFrame.getSqlDate()));
				}
			});
			confirmButton = new JButton("确定添加");
			confirmButton.setActionCommand("addDeanPost"); // 添加教务员
		} else {
			radioMan = new JRadioButton("男");
			radioFemal = new JRadioButton("女");
			ButtonGroup group = new ButtonGroup();
			group.add(radioMan);
			group.add(radioFemal);
			deanIdTextField = new JTextField(String.valueOf(dean.getDeaId()), 30);
			deanNoTextField = new JTextField(dean.getDeaNo(), 30);
			deanNameTextField = new JTextField(dean.getDeaName(), 30);
//			deanSexTextField = new JTextField(dean.getDeaSex(), 30);
			if(dean.getDeaSex().contentEquals("男")) {
				radioMan.setSelected(true);
			} else {
				radioFemal.setSelected(true);
			}
			deanAgeTextField = new JTextField(String.valueOf(dean.getDeaAge()), 30);
			deanAgeTextField.addKeyListener(new KeyAdapter() {
				public void keyTyped(KeyEvent e) {
				new FunctionFrame();
				deanAgeTextField.setText(String.valueOf(FunctionFrame.getSqlDate()));
				}
			});
			confirmButton = new JButton("确定修改");
			confirmButton.setActionCommand("updateDeanPost"); // 修改教务员
		}
		confirmButton.addActionListener(courseControllerListener);
		deanAddPanel.add(new JLabel("编号"));
		deanAddPanel.add(deanIdTextField);
		deanAddPanel.add(new JLabel("教职工号"));
		deanAddPanel.add(deanNoTextField);
		deanAddPanel.add(new JLabel("姓名"));
		deanAddPanel.add(deanNameTextField);
		deanAddPanel.add(new JLabel("性别"));
		deanAddPanel.add(radioMan);
		deanAddPanel.add(radioFemal);
		deanAddPanel.add(new JLabel("年龄"));
		deanAddPanel.add(deanAgeTextField);
		deanAddPanel.add(confirmButton);
		return deanAddPanel;
	}

	public CourseControllerListener getCourseControllerListener() {
		return courseControllerListener;
	}

	public void setCourseControllerListener(CourseControllerListener courseControllerListener) {
		this.courseControllerListener = courseControllerListener;
	}

	public JButton getConfirmButton() {
		return confirmButton;
	}

	public void setConfirmButton(JButton confirmButton) {
		this.confirmButton = confirmButton;
	}

	public Dean getDean() {
		return dean;
	}

	public void setDean(Dean dean) {
		this.dean = dean;
	}

	public JTextField getDeanIdTextField() {
		return deanIdTextField;
	}

	public void setDeanIdTextField(JTextField deanIdTextField) {
		this.deanIdTextField = deanIdTextField;
	}

	public JTextField getDeanNoTextField() {
		return deanNoTextField;
	}

	public void setDeanNoTextField(JTextField deanNoTextField) {
		this.deanNoTextField = deanNoTextField;
	}

	public JTextField getDeanNameTextField() {
		return deanNameTextField;
	}

	public void setDeanNameTextField(JTextField deanNameTextField) {
		this.deanNameTextField = deanNameTextField;
	}

	public JRadioButton getRadioMan() {
		return radioMan;
	}

	public void setRadioMan(JRadioButton radioMan) {
		this.radioMan = radioMan;
	}

	public JRadioButton getRadioFemal() {
		return radioFemal;
	}

	public void setRadioFemal(JRadioButton radioFemal) {
		this.radioFemal = radioFemal;
=======
import javax.swing.JButton;
import javax.swing.JDialog;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextField;
import course.controller.CourseControllerListener;
import course.po.Dean;

public class DeanDialog extends JDialog {
	private static final long serialVersionUID = 1L;
	private CourseControllerListener courseControllerListener;
	private JButton confirmButton;
	private JPanel deanAddPanel;
	private Dean dean;
	private JTextField deanIdTextField;
	private JTextField deanNoTextField;
	private JTextField deanNameTextField;
	private JTextField deanSexTextField;
	private JTextField deanAgeTextField;

	public DeanDialog(DeanJPanel owner, String title, Dean dean) {
		this.courseControllerListener = owner.getControllerListener();
		this.courseControllerListener.setDeanAddDialog(this);
		this.setTitle(title);
		this.dean = dean;
		this.add(getDeanAddPanel());
		this.setModal(true); // 设有模
		this.setSize(370, 530);
		this.setLocationRelativeTo(null);
		this.setResizable(false);
		this.setVisible(true);
		this.validate();
	}

	public void closeCurrentDialog() {
		this.setDefaultCloseOperation(DISPOSE_ON_CLOSE);
	}

	/**
	 * 添加/修改表单面板
	 * 
	 * @return
	 */
	private JPanel getDeanAddPanel() {
		deanAddPanel = new JPanel();
		deanAddPanel.setBackground(Color.orange);
		if ("添加教务员".equals(this.getTitle())) {
			deanIdTextField = new JTextField(30);
			deanNoTextField = new JTextField(30);
			deanNameTextField = new JTextField(30);
			deanSexTextField = new JTextField(30);
			deanAgeTextField = new JTextField(30);
			confirmButton = new JButton("确定添加");
			confirmButton.setActionCommand("addDeanPost"); // 添加教务员
		} else {
			deanIdTextField = new JTextField(String.valueOf(dean.getDeaId()), 30);
			deanNoTextField = new JTextField(dean.getDeaNo(), 30);
			deanNameTextField = new JTextField(dean.getDeaName(), 30);
			deanSexTextField = new JTextField(dean.getDeaSex(), 30);
			deanAgeTextField = new JTextField(String.valueOf(dean.getDeaAge()), 30);
			confirmButton = new JButton("确定修改");
			confirmButton.setActionCommand("updateDeanPost"); // 修改教务员
		}
		confirmButton.addActionListener(courseControllerListener);
		deanAddPanel.add(new JLabel("编号"));
		deanAddPanel.add(deanIdTextField);
		deanAddPanel.add(new JLabel("教职工号"));
		deanAddPanel.add(deanNoTextField);
		deanAddPanel.add(new JLabel("姓名"));
		deanAddPanel.add(deanNameTextField);
		deanAddPanel.add(new JLabel("性别"));
		deanAddPanel.add(deanSexTextField);
		deanAddPanel.add(new JLabel("年龄"));
		deanAddPanel.add(deanAgeTextField);
		deanAddPanel.add(confirmButton);
		return deanAddPanel;
	}

	public CourseControllerListener getCourseControllerListener() {
		return courseControllerListener;
	}

	public void setCourseControllerListener(CourseControllerListener courseControllerListener) {
		this.courseControllerListener = courseControllerListener;
	}

	public JButton getConfirmButton() {
		return confirmButton;
	}

	public void setConfirmButton(JButton confirmButton) {
		this.confirmButton = confirmButton;
	}

	public Dean getDean() {
		return dean;
	}

	public void setDean(Dean dean) {
		this.dean = dean;
	}

	public JTextField getDeanIdTextField() {
		return deanIdTextField;
	}

	public void setDeanIdTextField(JTextField deanIdTextField) {
		this.deanIdTextField = deanIdTextField;
	}

	public JTextField getDeanNoTextField() {
		return deanNoTextField;
	}

	public void setDeanNoTextField(JTextField deanNoTextField) {
		this.deanNoTextField = deanNoTextField;
	}

	public JTextField getDeanNameTextField() {
		return deanNameTextField;
	}

	public void setDeanNameTextField(JTextField deanNameTextField) {
		this.deanNameTextField = deanNameTextField;
	}

	public JTextField getDeanSexTextField() {
		return deanSexTextField;
	}

	public void setDeanSexTextField(JTextField deanSexTextField) {
		this.deanSexTextField = deanSexTextField;
>>>>>>> refs/remotes/origin/master
	}

	public JTextField getDeanAgeTextField() {
		return deanAgeTextField;
	}

	public void setDeanAgeTextField(JTextField deanAgeTextField) {
		this.deanAgeTextField = deanAgeTextField;
	}

	public void setDeanAddPanel(JPanel deanAddPanel) {
		this.deanAddPanel = deanAddPanel;
	}

}
